<?php 
	include $_SERVER['DOCUMENT_ROOT'].'/inc/core/env.inc.php';

	$u = $_POST["u"];
	$p = $_POST["p"];
	
	$_USER = new User($u, $p);
	
	if ($_USER->login){
		$_SESSION['uid'] = $_USER->get('id');
		$_SESSION['unick'] = $_USER->get('nick');
		$_SESSION['uemail'] = $_USER->get('email');
		$_SESSION['upass'] = $_USER->get('pass');
		$arr = array('result' => true, 'nick' => $_USER->get('nick'));
	} else {
		$description = 'Error to login from: '.$u.' - '.$p;
		$log = new Log(null, '/ajax/core/users/login.php', $description);
		$log->insert();
		$arr = array('result' => false);
	}
	
	echo '('.json_encode($arr).')';
?>